<?php

class FontLoginIdentity extends CUserIdentity {
	public function authenticate() {
		
		$worker = VAccount::model()->findByAttributes(array(
			'worker_name' => $this->username,
		));
		
		if(!$worker) {
			$this->errorCode=self::ERROR_USERNAME_INVALID;
			return false;
		} elseif ($worker->worker_password != $this->password){
			$this->errorCode=self::ERROR_PASSWORD_INVALID;
			return false;
		} else {
			$this->errorCode = self::ERROR_NONE;
			$this->setState('role', $worker->getAttribute('object_type'));
			$this->setState('id', $worker->id);
			return true;
		}
	}
}

?>